package edu.usm.cs.roberge;

/**
 * Utility class that provides static methods mostly for parsing the response
 * lines from the NewsGroup server
 * @author Dave
 *
 */
public class MessageUtility {

	public static boolean extractMessageIdFromStatResponse(String responseLine, Message message) {
		String tokens[] = responseLine.split(" ");
		if (tokens.length < 3) {
			return false;
		}
		
		if (!tokens[0].startsWith("223")) {
			return false;
		}
		
		message.setMessageNumber(tokens[1]);
		message.setMessageId(tokens[2]);
		
		return true;
	}

	public static String truncateZeros(String endMessage) {
		int i = Integer.parseInt(endMessage);
		return "" + i;
	}
}
